package com.smart.business.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.smart.entity.business.ChannelEntity;
import com.smart.mybatis.dao.BaseDao;
import com.smart.entity.business.CollectorEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


/**
 * 采集器配置
 *
 * @author wf
 * @since 2025-07-14 16:30:22
 */
@Mapper
public interface CollectorDao extends BaseDao<CollectorEntity> {

    void saveChannel(List<ChannelEntity> channels);


    List<String> isConnect(@Param("deleteIds") List<String>deleteIds);

    void deleteCollectors(@Param("deleteIds")List<String> deleteIds);

    @Select("select id,channel_number,create_date,ch,om,br,bd,bs,bc,di,parse_type from channel where collector_id = #{collectorId}")
    List<ChannelEntity> getChannelParamList(@Param("collectorId") String collectorId);


    List<String> getChannelIds(@Param("collectorIds") List<String> collectorIds);

    @Update("update channel set ch = #{channel.ch},om = #{channel.om},br = #{channel.br},bd = #{channel.bd},bs = #{channel.bs},bc = #{channel.bc},di = #{channel.di},parse_type = #{channel.parseType} where collector_id = #{channel.collectorId} and channel_number = #{channel.channelNumber}")
    void update(@Param("channel") ChannelEntity channel, LambdaQueryWrapper<ChannelEntity> wrapper);
    List<CollectorEntity> getCollectorList(@Param("name") String name, @Param("collectorNumber") String code,@Param("companyName") String companyName);

    void deleteChannelParam(@Param("collectorId") String collectorId,@Param("channelCount") Integer channelCount, @Param("oldChannelCount") Integer oldChannelCount);
}